package zero.tech.games.common;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import zero.tech.games.common.TopicOrder;
import zero.tech.games.common.marquee.Marquee;
import zero.tech.games.common.marquee.MarqueeAll;
import zero.tech.games.common.marquee.MarqueeClubAll;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.service.api.IRedisMsgService;

@Component
public class MarqueeUtil {
	@Autowired
	private IRedisMsgService redisMsgService;

	public void pushDynamicMarquee(String msg,Integer club_id,int... uids) {
		if(uids.length>0) {
			Marquee marquee = new Marquee();
			if(club_id!=null) {
				marquee.setClub_id(club_id);
			}
			marquee.setMsg(msg);
			for(int uid:uids) {
				marquee.getUids().add(uid);
			}
			redisMsgService.pulishRedisTopic(TopicChannelType.MARQUEE, TopicOrder.MARQUEE, marquee);
		}
	}
	
	public void pushDynamicMarqueeAll(String msg) {
		MarqueeAll marquee = new MarqueeAll();
		marquee.setMsg(msg);
		redisMsgService.pulishRedisTopic(TopicChannelType.MARQUEE, TopicOrder.MARQUEE_ALL, marquee);
	}
	public void pushDynamicMarqueeClubAll(String msg,int club_id) {
		MarqueeClubAll marquee = new MarqueeClubAll();
		marquee.setMsg(msg);
		marquee.setClub_id(club_id);
		redisMsgService.pulishRedisTopic(TopicChannelType.MARQUEE, TopicOrder.MARQUEE_CLUB_ALL, marquee);
	}
}
